<div class="panel">
  <h3>更新费用明细验证状态</h3>

  <div class="panel_contents">
    <div class="fee-detail-info">
      <h4>费用明细信息</h4>
      <table>
        <tr>
          <th>ID</th>
          <td><%= @fee_detail.id %></td>
        </tr>
        <tr>
          <th>报销单号</th>
          <td><%= @fee_detail.document_number %></td>
        </tr>
        <tr>
          <th>费用类型</th>
          <td><%= @fee_detail.fee_type %></td>
        </tr>
        <tr>
          <th>金额</th>
          <td><%= number_to_currency(@fee_detail.amount, unit: "¥") %></td>
        </tr>
        <tr>
          <th>费用日期</th>
          <td><%= @fee_detail.fee_date %></td>
        </tr>
        <tr>
          <th>支付方式</th>
          <td><%= @fee_detail.payment_method %></td>
        </tr>
        <tr>
          <th>当前验证状态</th>
          <td><%= @fee_detail.verification_status %></td>
        </tr>
      </table>
    </div>

    <div class="work-order-info">
      <h4>工单信息</h4>
      <table>
        <tr>
          <th>工单ID</th>
          <td><%= @work_order.id %></td>
        </tr>
        <tr>
          <th>工单类型</th>
          <td><%= @work_order.type.demodulize.underscore.humanize %></td>
        </tr>
        <tr>
          <th>工单状态</th>
          <td><%= @work_order.status %></td>
        </tr>
      </table>
    </div>

    <%
      # 使用多态路径，根据工单类型选择正确的控制器
      form_path = if @work_order.is_a?(AuditWorkOrder)
                    do_verify_fee_detail_admin_audit_work_order_path(@work_order)
                  elsif @work_order.is_a?(CommunicationWorkOrder)
                    do_verify_fee_detail_admin_communication_work_order_path(@work_order)
                  else
                    raise "不支持的工单类型: #{@work_order.class.name}"
                  end
    %>
    <%= form_tag form_path, method: :post do %>
      <%= hidden_field_tag :fee_detail_id, @fee_detail.id %>

      <div class="input">
        <label>验证状态</label>
        <%= select_tag :verification_status,
                      options_for_select([
                        ["待验证", "pending"],
                        ["有问题", "problematic"],
                        ["已验证", "verified"]
                      ], @fee_detail.verification_status) %>
      </div>

      <div class="input">
        <label>验证意见</label>
        <%= text_area_tag :comment, "", rows: 3 %>
      </div>

      <div class="actions">
        <%= submit_tag "提交", class: "button" %>
        <%= link_to "取消", polymorphic_path([:admin, @work_order]), class: "button" %>
      </div>
    <% end %>
  </div>
</div>

<style>
  .fee-detail-info, .work-order-info {
    margin-bottom: 20px;
  }

  .fee-detail-info table, .work-order-info table {
    width: 100%;
    border-collapse: collapse;
  }

  .fee-detail-info th, .fee-detail-info td,
  .work-order-info th, .work-order-info td {
    padding: 8px;
    border: 1px solid #ddd;
    text-align: left;
  }

  .fee-detail-info th, .work-order-info th {
    width: 120px;
    background-color: #f5f5f5;
  }

  .input {
    margin-bottom: 15px;
  }

  .input label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
  }

  .input select, .input textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  .actions {
    margin-top: 20px;
    text-align: right;
  }

  .button {
    margin-left: 10px;
  }
</style>